#ifndef CLIENT_H
#define CLIENT_H

#include <QObject>
#include <QTcpSocket>

/**
 *客户端
 * @brief The Client class
 */
class Client : public QObject
{
    Q_OBJECT
public:
    /**
     * @brief Client
     * @param serverIp 服务端ip
     * @param serverPort 服务端端口
     * @param parent
     */
    explicit Client(QString serverIp, quint16 serverPort, QObject *parent = nullptr);

    //连接服务端
    void connect();

    //断开
    void disConnect();
signals:
    //发送信号 收到的消息
    void signalReceiveMsg(QString msg);
public slots:
    //连接成功
    void connectSuccess();
    //读取数据
    void readServerData();
    QTcpSocket * getSocket(){
        return socket;
    }
private:
    //服务端端口
    quint16 serverPort = 8088;
    //服务端地址
    QHostAddress * serverAddress;
    //socket连接
    QTcpSocket * socket = nullptr;
};

#endif // CLIENT_H
